<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="../../js/vue.js"></script>
    <style>
        [v-cloak] {
            display: none;
        }

        .active {
            border: 1px solid red;
            width: 100px;
            height: 50px;
        }

        .color {
            background-color: darkseagreen;
        }
    </style>
</head>

<body>

    <dvi id="app">
        <!-- <div class="active"></div> -->

        <!-- 对象语法： -->
        <div v-bind:class="{active: isActive, color: isColor}">对象测试</div>
        <button @click="handle1">切换</button>
        <button @click="handle2">切换</button>

        <!-- 数组语法 -->
        <div v-bind:class="[activeClass, colorClass]">数组测试</div>
        <button @click="handle3">去除边框</button>
        <button @click="handle4">去除颜色</button>
        <button @click="handle5">恢复</button>
        <button @click="handle6">恢复</button>

        <!-- 简化： -->
        <div v-bind:class="arrClass">数组测试</div>
        <button @click="handle7">去除颜色</button>
        <div v-bind:class="objClass">数组测试</div>


    </dvi>

    <script>
        var vm = new Vue({
            el: "#app",
            data: {
                isActive: true,
                isColor: true,
                activeClass: "active",
                colorClass: "color",
                arrClass:["active", "color"],
                objClass:{
                    active:true,
                    color:false
                }
            },
            methods: {
                handle1() {
                    this.isActive = !this.isActive
                },
                handle2() {
                    this.isColor = !this.isColor
                },
                handle3() {
                    this.activeClass = ""
                },
                handle4() {
                    this.colorClass = ""
                },
                handle5() {
                    this.colorClass = "color"
                    this.activeClass = "active"
                },
                handle6() {
                    this.colorClass = "active name"
                },
                handle7() {
                    this.arrClass.pop()
                }
            }
        })
    </script>
</body>

</html>